package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ErrorCode;
import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * ClassName: CustomerController
 * Package: com.atguigu.jxc.controller
 * Description:
 *
 * @Author 梅超凡
 * @Create 2025/2/21 15:48
 * @Version 1.0
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;


    /**
     * 客户管理
     * @param page 页码
     * @param rows 每页显示条数
     * @param customerName 客户姓名
     * @return 返回结果
     */
    @PostMapping("/list")
    public Map<String, Object> customerList(Integer page, Integer rows, String customerName) {
        return customerService.customerList(page, rows, customerName);
    }



    /**
     * 保存或更新客户信息
     * @param customer 客户信息
     * @return 返回结果
     */
    @PostMapping("/save")
    public ServiceVO<Object> saveOrUpdate(@ModelAttribute Customer customer) {
        return customerService.saveOrUpdate(customer);
    }



    /**
     * 删除客户信息
     * @param ids 客户id
     * @return 返回结果
     */
    @PostMapping("/delete")
    public ServiceVO<Object> deleteById(String ids) {
        return customerService.deleteById(ids);
    }


}
